package io.github.wanggit.antrpc.console.web;

import io.github.wanggit.antrpc.console.service.GraphService;
import io.github.wanggit.antrpc.console.web.vo.CallLogTree;
import io.github.wanggit.antrpc.console.web.vo.CallLogsVO;
import io.github.wanggit.antrpc.console.web.vo.GraphVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("graph")
public class GraphController {

    @Autowired private GraphService graphService;

    @GetMapping("log_details")
    public CallLogsVO callLogsVODetails(@RequestParam(value = "rid") String requestId) {
        return graphService.findCallLogsVOByRequestId(requestId);
    }

    @GetMapping("call_graph_datas")
    public CallLogTree callGraphDatas(
            @RequestParam(value = "sn") String serialNumber,
            @RequestParam(value = "rid") String requestId) {
        return graphService.callGraphDatas(serialNumber, requestId);
    }

    @GetMapping("apps_data")
    public GraphVO graphDatas(@RequestParam(value = "qkw", required = false) String qkw) {
        return graphService.getApplicationGraph(qkw);
    }
}
